Revert alloc_idle_vcpu() to support multiple idle domains where max
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 10 Aug 2009 12:51:28 +0000 (13:51 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 10 Aug 2009 12:51:28 +0000 (13:51 +0100)
vcpus is less than max pcpus (e.g., can happen on i386).

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/common/domain.c

index a2507a7b3d34b56cee90f017e9b7d5fcff9cc098..175d837eaedb443b020e062886f38e45d28fcdc8 100644 (file)
@@ -182,8 +182,19 @@ struct vcpu *alloc_vcpu(
 
 struct vcpu *alloc_idle_vcpu(unsigned int cpu_id)
 {
-    return idle_vcpu[cpu_id] ?: alloc_vcpu(idle_vcpu[0]->domain,
-                                           cpu_id, cpu_id);
+    struct domain *d;
+    struct vcpu *v;
+    unsigned int vcpu_id = cpu_id % MAX_VIRT_CPUS;
+
+    if ( (v = idle_vcpu[cpu_id]) != NULL )
+        return v;
+
+    d = (vcpu_id == 0) ?
+        domain_create(IDLE_DOMAIN_ID, 0, 0) :
+        idle_vcpu[cpu_id - vcpu_id]->domain;
+    BUG_ON(d == NULL);
+
+    return alloc_vcpu(d, vcpu_id, cpu_id);
 }
 
 static unsigned int extra_dom0_irqs, extra_domU_irqs = 8;